<?php
define("OK",TRUE);
//ob_start();
header("Cache-control: public");
header("Content-type: text/html; charset=utf-8");
//header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
//header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//header("Cache-Control: store, no-cache, must-revalidate");
//header("Cache-Control: post-check=0, pre-check=0", FALSE);
//session_start();
header("P3P: CP=\"NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM\"");
// Psl. sugeneruotas per?
function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); }
define("starttime",getmicrotime());

//Bendri nustatymai ir funkcijos
require("variklis/bendras.php");
if (defined("DEBUG_EXTRA") && DEBUG_EXTRA)  echo round(getmicrotime()-starttime,3);
$AddInHead = "";//Tai kas bus HEAD tag'e

/*
//
// Puslapiai
//
if (isset($url['id']) && !empty($url['id']) && isnum($url['id'])) $id = (int) $url['id'];
else $id = 0;


if ($id == 0) $page = "modules/naujienos";
elseif ($id == 5) $page = "modules/apie";
elseif ($id == 6) $page = "modules/siustis";
elseif ($id == 9) $page = "modules/nuorodos";
elseif ($id == 7) $page = "modules/codebin";
elseif ($id == 22) $page = "modules/straipsnis";
elseif ($id == 25) $page = "modules/frm";
elseif ($id == 41) $page = "modules/reg";
elseif ($id == 42) $page = "modules/slaptazodzio_priminimas";////////////////////
elseif ($id == 44) $page = "modules/edit_user";
elseif ($id == 45) $page = "modules/pm";
elseif ($id == 46) {
	if(ADMIN) $page = "adm/index";//Administravimas
	else	$page = "modules/klaida";
}
elseif ($id == 47) $page = "modules/view_user";
elseif ($id == 48) {
	if(ADMIN) $page = "modules/test";//Administravimas
	else	$page = "modules/klaida";
} elseif ($id == 49) $page = "modules/shoutbox";
elseif ($id == 50) $page = "modules/naujienos";
elseif ($id == 66) $page = "modules/forumas";
/*elseif ($id > 999) {
	$psl_vid = $db->uzklausa("SELECT `page` FROM `projektai` WHERE `id`=".(int) $id."");
	if($db->rows($psl_vid) != 0) {
		$sql = $db->masyvas($psl_vid);
		$page = "projektai/" . $sql['page'];
	} else $page = "modules/klaida";
}/
else $page = "modules/klaida";
*/

/*
$sql = $db->uzklausa("SELECT * FROM `".T_MENIU."` WHERE `access`>='".LYGIS."' AND `which_meniu`='0' ORDER BY `parent`,`order` ASC");
$masyvas = $db->all_masyvas($sql);
tree_meniu($masyvas, 0, 0); //spausdinam meniu
unset($masyvas);
$db->free_result($sql);
*/
//
// smsAds
//
require("block/sms_reklama.php");
$tpl->setVar("smsReklama", $result);
unset($result);


//
// Vidurys content
//
ob_start();
//require $url_module;
$result = ob_get_contents();
ob_end_clean();
$tpl->setVar("content", $result);
unset($result);

// Jeigu neprisijunges rodyti Apie svetainę :)
if (!PRISIJUNGES) $ApieIfLoged = style_block($conf['Pavadinimas'], $conf['Apie']);
else $ApieIfLoged = "";
$tpl->setVar("ApieIfLogedIn", $ApieIfLoged);


// Class for blocks (OPTIONAL/Gali ir nebūti)
require("variklis/class/blocks.php");
//$tpl->setVar("left", blocks::block("L")); //Anksciau galejo buti toki variantai





//
// Footer/Apačia
//
unset($result);
$result = style_copyright_start();
$result .= (($conf['psl-load'] == 1) ? "Generavo: <div class=\"adm-info\">".round(getmicrotime()-starttime,3)."</div> s." : "") . $conf['Copyright'];

	$result .= "<br />MySQL užklausų: <div class=\"adm-info\">".$db->MysqlUzklausu."</div>; MySQL truko: <div class=\"adm-info\">".round($db->db_time,3)."</div>;<br />";
	$result .= "Svetainė naudoja: ".((function_exists('memory_get_usage')) ? baitai(memory_get_usage()) : 'klaida!')."; Iš jai skirtų: ".ini_get('memory_limit').";<br />";
	
	$result .= print_rr($db->uzklausos_info, true);
if (ADMIN) {

	
	if(defined("DEBUG_EXTRA") && DEBUG_EXTRA) {
		
		if(!empty($_POST))
			$result .= lentele("POST info", print_rr($_POST,true));
	}
	if (!empty($db->error))
		$result .= style_klaida("Mysql klaidos",$db->error);
}
$result .= style_copyright_end();
$tpl->setVar("copyright_debug", $result);


//
// Common variables used in tpl (P.S. MUST BE BEFORE DISPLAY)
//
if(!isset($page)) $page = "";//Tam, kad nemestu klaidos
$tpl->setVars(array(
	'title'			=> $conf['Pavadinimas'],
	'about'		=> $conf['Apie'],
	'tpl'			=> $conf['template'],
	'AddInHead'	=> $AddInHead)
);


//
// Display web page /Atvaizduojam svetainę
//
echo $tpl->display("bendras.tpl");

//print_rr($URL_additional);
//ob_end_flush();
?>
